package com.lagou.controller;

import com.lagou.service.AuthCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/code")
public class AuthCodeController {

    @Autowired
    private AuthCodeService authCodeService;

    @RequestMapping("/create/{email}")
    public Boolean create(@PathVariable("email") String email) {
        //生成验证码
        int code = (int) (Math.random() * 1000000);
        //持久化验证码
        authCodeService.addAuthCode(email, code + "");
        return true;
    }
}
